﻿@model internal_website.Models.Location
@using internal_website.CustomHtmlHelper
@using internal_website.Views.Resources

<fieldset>
    <legend>@ViewString.Location__Edit_Title</legend>
    <form>
        @Html.AntiForgeryToken()
        @Html.HiddenFor(model => model.Id)

        <section>
            <div class="row-fluid">
                <div class="span5">
                    <div class="control-group">
                        @Html.LabelFor(model => model.Active, new { @class ="control-label"})
                        <div class="controls">
                            @Html.CheckBoxFor(m => m.Active, new { @class="input-xlarge" })
                        </div>
                    </div>
                    <div class="control-group">
                        @Html.LabelFor(model => model.Name, new { @class ="control-label"})
                        <div class="controls">
                            @Html.MyTextBoxFor(model => model.Name, new {  @class="input-xlarge"})
                            @Html.ValidationMessageFor(model => model.Name, null, new { @class = "help-block" })
                        </div>
                    </div>
                    <div class="control-group">
                        @Html.LabelFor(model => model.Description, new { @class ="control-label"})
                        <div class="controls">
                            @Html.MyTextAreaFor(model => model.Description, new { @class="input-xlarge"})
                            @Html.ValidationMessageFor(model => model.Description, null, new { @class = "help-block" })
                        </div>
                    </div>
                    <div class="control-group">
                        @Html.LabelFor(model => model.Street, new { @class ="control-label"})
                        <div class="controls">
                            @Html.MyTextBoxFor(model => model.Street, new { @class="input-xlarge"})
                            @Html.ValidationMessageFor(model => model.Street, null, new { @class = "help-block" })
                        </div>
                    </div>
                    <div class="control-group">
                        @Html.LabelFor(model => model.PostalCode, new { @class ="control-label"})
                        <div class="controls">
                            @Html.MyTextBoxFor(model => model.PostalCode, new { @class="input-xlarge"})
                            @Html.ValidationMessageFor(model => model.PostalCode, null, new { @class = "help-block" })
                        </div>
                    </div>
                    <div class="control-group">
                        @Html.LabelFor(model => model.City, new { @class ="control-label"})
                        <div class="controls">
                            @Html.MyTextBoxFor(model => model.City, new { @class="input-xlarge"})
                            @Html.ValidationMessageFor(model => model.City, null, new { @class = "help-block" })
                        </div>
                    </div>
                    <div class="control-group">
                        @Html.LabelFor(model => model.Country, new { @class ="control-label"})
                        <div class="controls">
                            @Html.MyTextBoxFor(model => model.Country, new { @class="input-xlarge"})
                            @Html.ValidationMessageFor(model => model.Country, null, new { @class = "help-block" })
                        </div>
                    </div>
                    @Html.TextBoxFor(model => model.Latitude, new { style = "display: none;" })
                    @Html.TextBoxFor(model => model.Longitude, new { style = "display: none;" })
                </div>

                <div class="span2">
                </div>

                <div class="span5">
                    <div id="locationMap" class="span12" style="min-width:200px;height:400px; border:black solid 1px">
                    
                    </div>
                </div>

            </div>

        </section>


        <div class="control-group"> 
            <div class="controls pull-right">
                <button type="button" class="btn btn-danger btnCancel">@ViewString.Location__Edit_btnCancel_html</button>
                <button type="button" class="btn btn-success btnEdit">@ViewString.Location__Edit_btnEdit_html</button>
            </div>
        </div>

    </form>
</fieldset>

<script src="@Url.Content("~/Scripts/Locationprovider.js")"></script>
<script>
    @*http://leafletjs.com/*@
    var targetLatitude = @(Model.Latitude.ToString(System.Globalization.CultureInfo.InvariantCulture));
    var targetLongitude = @(Model.Longitude.ToString(System.Globalization.CultureInfo.InvariantCulture));
    var initialZoomFactor = @ViewString.Location__Edit_InitialMapZoomFactor.ToString(System.Globalization.CultureInfo.InvariantCulture);
    var mapMarkerDraggable = true;
    var mapClickable = true;

    var txtLatitudeSelector = "#@Html.IdFor(model => model.Latitude)";
    var txtLongitudeSelector = "#@Html.IdFor(model => model.Longitude)";
    var mapAreaSelector = 'locationMap';
    $(AddMap([targetLatitude, targetLongitude], initialZoomFactor, mapMarkerDraggable, mapClickable, txtLatitudeSelector, txtLongitudeSelector));
    
</script>